package cn.pfz.Service.impl;

import cn.pfz.Service.IPermissionSerives;
import cn.pfz.domain.Employee;
import cn.pfz.domain.Permission;
import cn.pfz.mapper.PermissionMapper;
import cn.pfz.query.QueryObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class IPermissionSerivesimpl implements IPermissionSerives {
    @Autowired
    private PermissionMapper permissionMapper;

    @Override
    public int deleteByPrimaryKey(Long id) {
        return permissionMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Permission record) {
        return permissionMapper.insert(record);
    }

    @Override
    public Permission selectByPrimaryKey(Long id) {
        return permissionMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Permission> selectAll() {
        return permissionMapper.selectAll();
    }

    @Override
    public int updateByPrimaryKey(Permission record) {
        return permissionMapper.updateByPrimaryKey(record);
    }

    @Override
    public PageInfo<Permission> selectRusult(QueryObject qo) {
        //通过pageHelper进行设置分页及排序
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize(),"id asc");
        //在Sql中不需要limit
        List<Permission> Employees = permissionMapper.selectRusult(qo);
        PageInfo<Permission> PageInfo = new PageInfo(Employees);
        return PageInfo;
    }

    @Override
    public List<Permission> selectByEmployee(Long id) {
        return permissionMapper.selectByEmployee(id);
    }

    @Override
    public List<String> getPermissionExperssionByEmployeeId(Long id) {
        return permissionMapper.getPermissionExperssionByEmployeeId(id);
    }
}
